#-*-coding=utf-8-*-
from google.appengine.ext import db
from google.appengine.api import users
from datetime import datetime
from core.file.models import File

class Profile(db.Model):
    user = db.UserProperty()
    avater = db.ReferenceProperty(File)
    created = db.DateTimeProperty(auto_now_add = True)
    last_login = db.DateTimeProperty()
    
    @classmethod
    def create_profile(cls, user):
        if user:
            instance = cls(user = user)
            instance.last_login = datetime.now()
            instance.put()
            return instance
        return None
    
    
